function atValidOccupancyEvents = DiscardInvalidEvents( atOccupancyEvents )
	%
	% count the number of valid events
	iNumberOfValidEvents = 0;
	%
	for iEvent = 1:numel( atOccupancyEvents )
		%
		if( atOccupancyEvents(iEvent).bIsValid )
			%
			iNumberOfValidEvents = iNumberOfValidEvents + 1;
			%
		end;%
		%
	end;%
	%
	% before continuing, check if there are no valid events. In case, return
	if( iNumberOfValidEvents <= 0 )
		%
		atValidOccupancyEvents = [];
		return;
		%
	end;%
	%
	% allocate the storage
	atValidOccupancyEvents(iNumberOfValidEvents) = PeopleCounters.OccupancyEvent();
	%
	% save the valid events
	iNumberOfSavedEvents = 0;
	%
	for iEvent = 1:numel( atOccupancyEvents )
		%
		if( atOccupancyEvents(iEvent).bIsValid )
			%
			iNumberOfSavedEvents = iNumberOfSavedEvents + 1;
			atValidOccupancyEvents(iNumberOfSavedEvents) = atOccupancyEvents(iEvent);
			%
		end;%
		%
	end;%
	%
end % function

